const express=require('express');
const static=require('express-static');
const bodyParser=require('body-parser');
const multer=require('multer');
const multerObj=multer({dest:'./www/img'});
const mysql=require('mysql');
const cookieParser=require('cookie-parser');
const cookieSession=require('cookie-session');
const consolidate=require('consolidate');
const ejs=require('ejs');
const expressRoute=require('express-route');

//Router--->node
//route --->express-route
var server=express();
server.listen(8083);

//1.获取请求数据
server.use(multerObj.any());
server.use(bodyParser.urlencoded({extended:false}));
//server.use(bodyParser.urlencoded());
//2cookie
server.use(cookieParser('lkjhgfdsqwertymnbvh'));
//server.use(cookieSession({
//	name:
//	keys:
//	maxAge:
//}));
//3、session
(function(){
    var keys=[];
    for(var i=0;i<100000;i++)
    {
        keys[i]="keys_"+Math.random();
    }
    server.use(cookieSession({
        name:'userId',
        keys:keys,
        maxAge:20*60*1000   //20min
    }));
})();
//路由后台login页面
server.use('/web/',require('./route/web/login.js')());
//路由后台首页idenx
server.use('/web/',require('./route/web/index.js')());
//一级分类
server.use('/web/',require('./route/web/PrimaryClassification.js')());//显示列表
server.use('/web/',require('./route/web/AddPrimaryClassification.js')());//添加分类路由
server.use('/web/',require('./route/web/updatePrimaryClassification.js')());//修改分类

//二级分类
server.use('/web/',require('./route/web/TheSecondary/TheSecondary.js')());//x显示
server.use('/web/',require('./route/web/TheSecondary/AddPrimaryClassification.js')());//添加
server.use('/web/',require('./route/web/TheSecondary/updateTheSecondary.js')());//修改分类
//商品
server.use('/web/',require('./route/web/ertiaryGoods/ertiaryGoods.js')());//x显示
server.use('/web/',require('./route/web/ertiaryGoods/AddertiaryGoods.js')());//添加
server.use('/web/',require('./route/web/ertiaryGoods/displayertiaryGoods.js')());//显示详情
server.use('/web/',require('./route/web/ertiaryGoods/updateertiaryGoods.js')());//差修改

//公告
server.use('/web/',require('./route/web/Billboard/Billboard.js')());//x显示
server.use('/web/',require('./route/web/Billboard/AddBillboard.js')());//添加
server.use('/web/',require('./route/web/Billboard/displayertBillboard.js')());//显示详情
server.use('/web/',require('./route/web/Billboard/updatBillboard.js')());//显示详情

//活动
server.use('/web/',require('./route/web/newest/newest.js')());//x显示
server.use('/web/',require('./route/web/newest/Addnewest.js')());//添加
server.use('/web/',require('./route/web/newest/displanewest.js')());//详情
server.use('/web/',require('./route/web/newest/updatnewest.js')());//修改详情
//用户
server.use('/web/',require('./route/web/uerinfo/uerinfo.js')());//x显示
server.use('/web/',require('./route/web/uerinfo/Adduerinfo.js')());//添加
server.use('/web/',require('./route/web/uerinfo/displauerinfo.js')());//详情
server.use('/web/',require('./route/web/uerinfo/updatuerinfo.js')());//修改详情

//租聘
server.use('/web/',require('./route/web/leaseInfo/leaseInfo.js')());//x显示
server.use('/web/',require('./route/web/leaseInfo/displayertleaseInfo.js')());//显示详情
server.use('/web/',require('./route/web/leaseInfo/updatleaseInfo.js')());//修改

//商品收藏
server.use('/web/',require('./route/web/Collection/Collection.js')());//x显示
server.use('/web/',require('./route/web/Collection/displayerCollection.js')());//显示详情
server.use('/web/',require('./route/web/Collection/updatCollection.js')());//修改

//评论
server.use('/web/',require('./route/web/critical/critical.js')());//x显示
server.use('/web/',require('./route/web/critical/displacritical.js')());//显示详情
server.use('/web/',require('./route/web/critical/Addcritical.js')());//添加
server.use('/web/',require('./route/web/critical/updatcritical.js')());//修改
//banner
server.use('/web/',require('./route/web/homepagebanner/homepagebanner.js')());//x显示
server.use('/web/',require('./route/web/homepagebanner/Addhomepagebanner.js')());//添加
server.use('/web/',require('./route/web/homepagebanner/updathomepagebanner.js')());//修改

//首页接口
server.use('/HomePageInterface/',require('./route/HomePageInterface/index.js')());//x显示
server.use('/HomePageInterface/',require('./route/HomePageInterface/login.js')());//前台登陆注册
server.use('/HomePageInterface/',require('./route/HomePageInterface/ListDetails.js')());//分类详情页
server.use('/HomePageInterface/',require('./route/HomePageInterface/self.js')());//个人中心

server.use('/HomePageInterface/',require('./route/HomePageInterface/ForumClass.js')());//论坛首页
server.use('/HomePageInterface/',require('./route/HomePageInterface/ForumDiscuss.js')());//论坛模块
server.use('/HomePageInterface/',require('./route/HomePageInterface/ForumDetails.js')());//论坛详情
server.use('/HomePageInterface/',require('./route/HomePageInterface/ForumReply.js')());//论坛评论


server.use('/web/',require('./route/web/复制 index.js')());
server.use('/web/',require('./route/web/添加的公共模板AddTeachersinformation.js')());
//处理模板
server.engine('html',consolidate.ejs);
server.set('views','template');
server.set('view engine','html');


//访问文件
server.use(static('www'));

